package dateBase;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sports_meet.R;

import java.util.List;

import site.SiteBean;

public class SiteAdapter extends BaseAdapter {
    private Context mContext;
    private List<SiteBean> site_list;

    public SiteAdapter(Context context, List<SiteBean> site_list) {
        this.site_list = site_list;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return site_list.size();
    }

    @Override
    public Object getItem(int i) {
        return site_list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.site_item, parent, false);
        }
//     获取数据类型的对象
        SiteBean data = (SiteBean) getItem(position);

        // 设置视图中的控件的值
        TextView textView1 = convertView.findViewById(R.id.item_1);
        TextView textView2 = convertView.findViewById(R.id.item_2);
        TextView textView3 = convertView.findViewById(R.id.item_3);
        TextView textView4 = convertView.findViewById(R.id.item_4);
        TextView textView5 = convertView.findViewById(R.id.item_5);

        textView1.setText(data.getSno());
        textView2.setText(data.getSname());
        textView3.setText(data.getScapacity());
        textView4.setText(data.getStypes());
        textView5.setText(data.getSaddress());


        return convertView;
    }
}
